const Router = require("@koa/router");
const {
  register,
  login,
  changePassword,
} = require("../controller/userController");
const router = new Router({ prefix: "/users" });
const {
  userValidator,
  verifyUser,
  cryptPassword,
  verifyLogin,
} = require("../middleware/userMiddleware");
const { auth } = require("../middleware/authMiddleware");
// 1、用户注册
router.post("/register", userValidator, verifyUser, cryptPassword, register);

// 2、用户登录
router.post("/login", userValidator, verifyLogin, login);

// 3、修改密码
router.patch("/", auth, cryptPassword, changePassword);

module.exports = router;
